package com.mindfactory.pwdbox.activity;

import java.util.ArrayList;
import java.util.HashMap;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.mindfactory.pwdbox.R;

public class PasswordListAdapter extends BaseAdapter{

	private ArrayList<HashMap<String, String>> list;
	private Context context;
	
	public PasswordListAdapter(ArrayList<HashMap<String, String>> list , Context context) {
		this.list = list;
		this.context = context;
	}
	
	@Override
	public int getCount() {
		
		return list.size();
	}

	@Override
	public Object getItem(int position) {

		return list.get(position);
	}

	@Override
	public long getItemId(int position) {

		return Integer.parseInt(list.get(position).get("id"));
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		LayoutInflater layoutInflater =LayoutInflater.from(context);
		View rowView = layoutInflater.inflate(R.layout.pwd_item, null);
		TextView pwdText = (TextView) rowView.findViewById(R.id.pwdListText);
		
		pwdText.setText(list.get(position).get("name"));
		
		return rowView;
	}
}